package com.mallcai.bigdata.ladon.controller.peekdata.form;

import com.mallcai.bigdata.ladon.controller.BaseForm;
import com.mallcai.bigdata.ladon.dpl.entity.peekdata.Tag;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotNull;

/**
 * @author feixy
 * @version 1.0
 * @date 2019-06-25 18:34
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class TagForm  extends BaseForm {

    @NotNull(message = "主键不能为空", groups = {TagForm.EditCheck.class, TagForm.IdCheck.class})
    private Long   id;
    @NotNull(message = "标签名称不能为空", groups = {TagForm.AddCheck.class, TagForm.EditCheck.class})
    private String name;
    @NotNull(message = "匹配值不能为空", groups = {TagForm.AddCheck.class, TagForm.EditCheck.class})
    private String rule;   // 返回的数据字段名列表, 多个以","隔开

    public interface IdCheck {
    }
    public interface AddCheck {
    }

    public interface EditCheck {
    }


    public Tag toEntity() {
        Tag p = new Tag();
        BeanUtils.copyProperties(this, p);
        return p;
    }
}
